/**
 * Generali Solutions d'assurances - Tous droits réservés &copy; 2007 - 2010
 */
package fr.generali.accueilclient.table.param.impl;

import fr.generali.accueilclient.table.param.ITableParam;

/**
 * @author Holmes Kelly
 */
public class TableParam implements ITableParam {

    /**
     * code
     */
    private String code;

    /**
     * system origine
     */
    private String systemOrigine;

    /**
     * {@inheritDoc}
     */
    public String getCode() {
        return code;
    }

    /**
     * {@inheritDoc}
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * {@inheritDoc}
     */
    public String getSystemOrigine() {
        return systemOrigine;
    }

    /**
     * {@inheritDoc}
     */
    public void setSystemOrigine(String systemOrigine) {
        this.systemOrigine = systemOrigine;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean equals(Object obj) {

        boolean isEqual = false;

        if (this == obj) {

            return true;
        }

        if (obj != null && obj.getClass().getName().equals(this.getClass().getName())) {
            final TableParam tableParamCompare = (TableParam ) obj;

            boolean isTableParamNonNull = this.getCode() != null && this.getSystemOrigine() != null;

            boolean isTableParamCompareNonNull =
                            tableParamCompare.getCode() != null && tableParamCompare.getSystemOrigine() != null;

            boolean isTableParamNull = this.getCode() == null && this.getSystemOrigine() == null;

            boolean isTableParamCompareNull =
                            tableParamCompare.getCode() == null && tableParamCompare.getSystemOrigine() == null;

            if (isTableParamNonNull && isTableParamCompareNonNull) {

                isEqual = this.getCode().equals(tableParamCompare.getCode());
                isEqual = isEqual && this.getSystemOrigine().equals(tableParamCompare.getSystemOrigine());

            }

            if (isTableParamNull && isTableParamCompareNull) {

                isEqual = super.equals(obj);
            }

        }

        return isEqual;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public int hashCode() {

        int hashCode = 0;

        int multiplier = 33;

        boolean isTableParamNonNull = this.getCode() != null && this.getSystemOrigine() != null;

        boolean isTableParamNull = this.getCode() == null && this.getSystemOrigine() == null;

        if (isTableParamNonNull) {
            hashCode = multiplier * hashCode + this.getCode().hashCode();
            hashCode = multiplier * hashCode + this.getSystemOrigine().hashCode();
        }
        if (isTableParamNull) {
            return super.hashCode();
        }

        return hashCode;
    }

}
